package cn.izeno.wx.models.component

import com.alibaba.fastjson.annotation.JSONField

/**
 * 公众号/小程序的接口条用凭证
 */
class AppToken {
  @field:JSONField(name = "authorizer_access_token")
  var accessToken: String = ""

  @field:JSONField(name = "authorizer_refresh_token")
  var refreshToken: String = ""
  /**
   * 有效期 (s)
   */
  @field:JSONField(name = "expires_in")
  var expiredAt: Long = 7200L
    set(value) {
      field = when (value) {
        7200L -> System.currentTimeMillis() + value * 1000
        else -> value
      }
    }
}
